<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fn(nums){
            if (nums.length<2) return nums.length
            nums.sort((a,b)=>a-b)
            let max = 1
            let k = 0
            let left = 0 
            let right = 1
            while(right<nums.length){
                if(nums[right-1]+1 === nums[right]){
                    right++
                    max = Math.max(max,right-left-k)
                }else if (nums[right-1] === nums[right]){
                    k++
                    right++
                }else{
                    k=0
                    left = right
                    right++
                }
            }
            return max
        }
        console.log(fn([0,3,7,2,5,8,4,6,0,1]))
    </script>
</body>
</html>